package com.qfedu.controller;

import com.github.pagehelper.PageInfo;
import com.qfedu.entity.Cargoreceipt;
import com.qfedu.service.VehicleService;
import com.qfedu.util.PageHelperUtil;
import com.qfedu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * projectName: logistics
 * author: CGY
 * time: 2020/10/10 10:09
 * description:货运单回执类
 */
@RestController
@RequestMapping("/vehicle")
public class VehicleController {

    @Autowired
    private VehicleService vehicleService;

    /**
     * 查询货运回执单编号
     * @return
     */
    @RequestMapping("/selectLeftCodes.do")
    public Result selectLeftCodes(){
        return vehicleService.selectLeftCodes();
    }

    /**
     * 通过货运回执单查询客户信息
     * @param goodsRevertBillId
     * @return
     */
    @RequestMapping("/findGoodsBill.do")
    public Result findGoodsBill(String goodsRevertBillId){
        return vehicleService.findGoodsBill(goodsRevertBillId);
    }

    /**
     * 添加货运回执单
     * @param cargoreceipt
     * @return
     */
    @RequestMapping("/add.do")
    public Result add(Cargoreceipt cargoreceipt){
        return vehicleService.add(cargoreceipt);
    }

    /**
     * 查询运单状态
     * @param backBillState
     * @param pageNum
     * @param limit
     * @return
     */
    @RequestMapping("/select.do")
    public PageHelperUtil select(String backBillState, Integer pageNum, Integer limit){
        System.out.println("backBillState = " + backBillState);
        PageInfo pageInfo = vehicleService.select(backBillState,pageNum,limit);

        return PageHelperUtil.success(pageInfo.getTotal(),pageInfo.getList());
    }

    /**
     * 通过id查询单个货运单
     * @param goodsRevertBillCode
     * @return
     */
    @RequestMapping("/selectByCode.do")
    public Result selectByCode(String goodsRevertBillCode){
        return vehicleService.selectByCode(goodsRevertBillCode);
    }
}
